﻿// *----------------------------------------------------------------
// Copyright (C) 2017 通通优品
// 版权所有。
// 
// 类名：AutoRepositoryTypesAttribute.cs
// 功能描述：TongTongMall.Dapper
// 
// Create User：jym 2017/02/09
// 
// Edit User：UserName,EditTime
// Describe：Describe
// ----------------------------------------------------------------*/
using System;
using TongTongMall.Dapper.Repository;
using TongTongMall.Domain.Repositories.Repositories;

namespace TongTongMall.Dapper.Registrar
{
    /// <summary>
    /// 根据此属性 映射仓储类与实体之间的关系
    /// </summary>
    [AttributeUsage(AttributeTargets.Class)]
    public class AutoRepositoryTypesAttribute : Attribute
    {
        public static AutoRepositoryTypesAttribute Default { get; private set; }

        public Type RepositoryInterface { get; private set; }

        public Type RepositoryInterfaceWithPrimaryKey { get; private set; }

        public Type RepositoryImplementation { get; private set; }

        public Type RepositoryImplementationWithPrimaryKey { get; private set; }

        static AutoRepositoryTypesAttribute()
        {
            Default = new AutoRepositoryTypesAttribute(
//                typeof(IRepository<>),
                typeof(IRepository<,>),
                typeof(DapperRepositoryBase<,>)
//                typeof(DapperRepositoryBase<,>)
                );
        }

        public AutoRepositoryTypesAttribute(
            //Type repositoryInterface,
            Type repositoryInterfaceWithPrimaryKey,
            //Type repositoryImplementation,
            Type repositoryImplementationWithPrimaryKey)
        {
            //RepositoryInterface = repositoryInterface;
            RepositoryInterfaceWithPrimaryKey = repositoryInterfaceWithPrimaryKey;
            //RepositoryImplementation = repositoryImplementation;
            RepositoryImplementationWithPrimaryKey = repositoryImplementationWithPrimaryKey;
        }
    }
}
